export default {
  name: "testPaper-mixin",
  data() {
    return {

    }
  },

  methods: {
    //导航题目类型名称
    topicTypeName_mixin(type) {
      switch (type) {
        case 0:
          return '一、常识判断';
        case 1:
          return '二、言语理解与表达';
        case 2:
          return '三、数量关系';
        case 3:
          return '四、判断推理';
        case 4:
          return '五、资料分析';
      }
    },

    //获取答题的题号顺序
    bigQuestionIndex(index) {
      var bigQuestion = ['一、', '二、', '三、', '四、', '五、', '六、'];
      var nav_i = 0;
      for (let i = 0; i < index; i++) {
        if (this.sortedTopics[i].topic_content.length != 0) {
          nav_i += 1;
        }
      }
      return bigQuestion[nav_i];
    },

    //答题类型名称
    bigQuestionName_mixin(type, index) {
      let nav_i = this.bigQuestionIndex(index);
      switch (type) {
        case 0:
          return nav_i + '常识判断';
        case 1:
          return nav_i + '言语理解与表达';
        case 2:
          return nav_i + '数量关系';
        case 3:
          return nav_i + '判断推理';
        case 4:
          return nav_i + '资料分析';
      }


    },

    //回到顶部
    backTop_mixin() {
      document.body.scrollTop = document.documentElement.scrollTop = 0;
    },


    //计算題号
    topicNavIndex_mixin(groupedIndex, questionIndex) {
      let navIndex = 0;
      for (let i = 0; i < groupedIndex; i++) {
        navIndex = navIndex + this.examData.groupedQuestions[i].questions.length;
      }
      return navIndex + questionIndex + 1;
    },

    /*数字返回汉字,最大 千亿 */
    returnCN(num) {
      let changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
      let unit = ["", "十", "百", "千", "万"];
      let getCh = (temp) => {
        let strArr = temp.toString().split("").reverse();
        let newNum = "";
        for (let i = 0; i < strArr.length; i++) {
          newNum = (i == 0 && strArr[i] == 0 ? "" : (i > 0 && strArr[i] == 0 && strArr[i - 1] == 0 ? "" : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i]))) + newNum;
        }
        return newNum;
      }
      let ny = Math.floor(num / 100000000);
      num = ny ? (num - ny * 100000000) : num;
      let nw = Math.floor(num / 10000);
      num = nw ? (num - nw * 10000) : num;
      return ny ? getCh(ny) + '亿' + getCh(nw) + '万' + getCh(num) : nw ? getCh(nw) + '万' + getCh(num) : getCh(num);
    }







  },

}